package slog

import (
	"gitee.com/yysf_xin/go-common/tools"
	"time"
)

type MessageImpl struct {
	Time time.Time `gorm:"index"`
	Level,
	Thread,
	AppName string
	TraceID string `gorm:"index"`
	Logger,
	Method string
	Message    string `gorm:"size:2048"`
	SubMessage string `gorm:"size:2048"`
}

func (m *MessageImpl) GetThread() string {
	return m.Thread
}
func (m *MessageImpl) GetTime() *time.Time {
	return &m.Time
}

func (m *MessageImpl) GetMessage() []byte {
	return tools.StringToBytes(m.Message)
}

func (m *MessageImpl) GetSubMessage() []byte {
	return tools.StringToBytes(m.SubMessage)
}

func (m *MessageImpl) GetLevel() string {
	return m.Level
}

func (m *MessageImpl) GetLogger() string {
	return m.Logger
}

func (m *MessageImpl) GetMethod() string {
	return m.Method
}

func (m *MessageImpl) GetTrace() string {
	return m.TraceID
}

func (m *MessageImpl) SetSubMessage(sub []byte) {
	m.SubMessage = tools.BytesToString(sub)
}

func (m *MessageImpl) Reset() {
	m.SubMessage = ""
}
